package info.jafe.common.util;

import android.os.Handler;

import info.jafe.common.context.ContextProvider;
import info.jafe.common.exception.UnRegisteredException;

/**
 * Created by jafe chang on 2016/12/17.
 */
public class PostUtils {
    public static void run(Runnable runnable) {
        Handler handler = ContextProvider.getHandler();
        if (handler == null) {
            throw new UnRegisteredException(UnRegisteredException.APPLICATION_UNREGISTERED);
        }
        handler.post(runnable);
    }

    public static void run(Runnable runnable, long delayMillis) {
        Handler handler = ContextProvider.getHandler();
        if (handler == null) {
            throw new UnRegisteredException(UnRegisteredException.APPLICATION_UNREGISTERED);
        }
        handler.postDelayed(runnable, delayMillis);
    }
}
